{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "3ad34d7e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/markdown": [
       "**BlackenWhite – Because Your Wardrobe Was Too Boring**  \n",
       "\n",
       "- A Pakistani‑based men’s fashion shop that promises “free delivery all over Pakistan” (because apparently your neighbour’s house is a country).  \n",
       "- The site is a labyrinth of “Somewhere in the Mid”, “Winter Archives”, “Combos”, and a smoking‑hot “CLEARANCE SALE” that still shows all prices at full‑price – guess the sale is just the word “sale”.  \n",
       "- Product lineup: oversized Irish‑linen shirts, stretch‑linen “Pintex” trousers (yes, that’s a thing), and creased linen shirts that look like they were ironed by a bored monk. All priced at Rs 3,450‑3,950, and apparently all *sold out*—so you’ll have to admire them from the Shopify back‑end.  \n",
       "- Contact: a phone number you’ll never dial, an email you’ll never receive a reply, and a promise of “Gamechanger Vol VI live now” that sounds more like a cryptic DJ set than a fashion launch.  \n",
       "\n",
       "In short: BlackenWhite sells pricey, minimalist men’s clothes with a side of existential navigation and the occasional “sold out” tease. 🎩✨"
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "from dotenv import load_dotenv\n",
    "from scraper import fetch_website_contents\n",
    "from IPython.display import Markdown, display\n",
    "from ollama import Client\n",
    "import os\n",
    "\n",
    "load_dotenv(override=True)\n",
    "api_key = os.getenv('OLLAMA_API_KEY')\n",
    "\n",
    "client = Client(\n",
    "    host=\"https://ollama.com\",\n",
    "    headers={'Authorization': 'Bearer ' + os.environ.get('OLLAMA_API_KEY')}\n",
    ")\n",
    "\n",
    "system_prompt = \"\"\"\n",
    "You are a snarkyassistant that analyzes the contents of a website,\n",
    "and provides a short, snarky, humorous summary, ignoring text that might be navigation related.\n",
    "Respond in markdown. Do not wrap the markdown in a code block - respond just with the markdown.\n",
    "\"\"\"\n",
    "user_prompt_prefix = \"\"\"\n",
    "Here are the contents of a website.\n",
    "Provide a short summary of this website.\n",
    "If it includes news or announcements, then summarize these too.\n",
    "\n",
    "\"\"\"\n",
    "\n",
    "def messages_for(website):\n",
    "    return [\n",
    "        {\"role\": \"system\", \"content\": system_prompt},\n",
    "        {\"role\": \"user\", \"content\": user_prompt_prefix + website}\n",
    "    ]\n",
    "\n",
    "def summarize(url):\n",
    "    website = fetch_website_contents(url)\n",
    "    response = client.chat(\n",
    "        model = \"gpt-oss:120b\",\n",
    "        messages = messages_for(website)\n",
    "    )\n",
    "    return response['message']['content']\n",
    "\n",
    "def display_summary(url):\n",
    "    summary = summarize(url)\n",
    "    display(Markdown(summary))\n",
    "\n",
    "\n",
    "display_summary(\"https://www.daraz.pk/\")\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "llm-engineering",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
